package com.baimuzhi.live.service;

import com.baimuzhi.live.entity.Live;
import com.baimuzhi.live.entity.LiveConfig;
import com.baimuzhi.live.entity.LiveConfigList;
import com.baimuzhi.live.utils.ConfigBuild;
import com.baimuzhi.live.utils.ConfigUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName : ConfigService
 * @Description :
 * @Author : 肖叶茂
 * @Date: 2023/1/18  16:29
 */

@Service
public class ConfigService {

    @Autowired
    private ConfigBuild configBuild;

    public LiveConfig getOneById(String id){

        if(configBuild == null){
            return  null;
        }

        if(configBuild.getLiveConfigList() == null){
            return null;
        }

        if(configBuild.getLiveConfigList().isEmpty()){
            return null;
        }

        for(LiveConfig liveConfig : configBuild.getLiveConfigList()){
            if(liveConfig.getId() == null){
                return null;
            }

            if(liveConfig.getId().equals(id)){
                return liveConfig;
            }
        }

        return null;
    }
}
